package com.sms.templateservice.controller;

import com.sms.common.result.Result;
import com.sms.templateservice.entity.SmsTemplate;
import com.sms.templateservice.service.SmsTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sms/template")
public class SmsTemplateController {
    
    @Autowired
    private SmsTemplateService smsTemplateService;
    
    /**
     * 申请模板
     */
    @PostMapping("/apply")
    public Result<String> applyTemplate(@RequestBody SmsTemplate template) {
        return smsTemplateService.applyTemplate(template);
    }
    
    /**
     * 审核模板
     */
    @PostMapping("/audit")
    public Result<String> auditTemplate(@RequestParam Long templateId,
                                      @RequestParam Integer auditStatus,
                                      @RequestParam String auditOpinion,
                                      @RequestParam Long auditorId) {
        return smsTemplateService.auditTemplate(templateId, auditStatus, auditOpinion, auditorId);
    }
    
    /**
     * 启用/禁用模板
     */
    @PostMapping("/toggle")
    public Result<String> toggleTemplate(@RequestParam Long templateId,
                                       @RequestParam Integer enabled) {
        return smsTemplateService.toggleTemplate(templateId, enabled);
    }
    
    /**
     * 获取模板详情
     */
    @GetMapping("/detail/{templateId}")
    public Result<SmsTemplate> getTemplateDetail(@PathVariable Long templateId) {
        return smsTemplateService.getTemplateDetail(templateId);
    }
    
    /**
     * 分页查询模板列表
     */
    @GetMapping("/list")
    public Result<Object> getTemplateList(
            @RequestParam(name = "pageNum", defaultValue = "1", required = false) Integer pageNum,
            @RequestParam(name = "pageSize", defaultValue = "10", required = false) Integer pageSize,
            @RequestParam(name = "templateName", required = false) String templateName,
            @RequestParam(name = "templateType", required = false) Integer templateType,
            @RequestParam(name = "auditStatus", required = false) Integer auditStatus) {

        return null ;//smsTemplateService.getTemplateList(pageNum, pageSize, templateName, templateType, auditStatus);
    }
} 